import React from 'react'
import store from '../../app/store'
import { incre, decre, asyncIncreAction } from '../../app/slices/countSlice';
import { incre as add } from '../../app/slices/zanSlice';
import {incre as inc} from '../../app/slices/collSlice'

export default function ReduxCom() {
  return (
    <div>
      <h2>{store.getState().count}</h2>
      <button onClick={() => {
        store.dispatch(incre(5));
      }}>新增</button>
      <button onClick={() => {
        store.dispatch(decre(1));
      }}>减少</button>
      <button onClick={() => {
        store.dispatch(asyncIncreAction(5));
      }}>1s后新增100</button>
      <hr />
      <h2>点赞数: {store.getState().zan}</h2>
      <button onClick={() => {
        store.dispatch(add(10));
      }}>点赞</button>

      <hr />
      <h2>收藏数 {store.getState().coll.value}</h2>
      <button onClick={() => {
        store.dispatch(inc());
      }}>收藏</button>
    </div>
  )
}
